package fr.univnantes.lina.uima.connectors.ftb;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import fr.univnantes.lina.java.util.CollectionUtilities;
import fr.univnantes.lina.uima.connectors.xml.XMLSaxHandler;

public class FTBPropertiesCollectorAndCompiler {

	public FTBPropertiesCollectorAndCompiler() {
		super();
	}

	/**
	 * Compile a list of mw ngu  
	 * @param indent
	 * @param n
	 */
	public Map<String,WordLemma> collectPropertiesFromMultiWordNodeList(NodeList nodeList) {

		int distinctLemma = 0;
		int numberOfOccurrences = 0;

		Map<String,WordLemma> multiWordsExpressionHashMap = new HashMap<String,WordLemma>() ;

		// for each mw occurrences
		for(int i=0; (i < nodeList.getLength()); i++) {
			if (nodeList.item(i) instanceof Element) {
				Element aMWEe = (Element) nodeList.item(i);

				// Compute MW characteristics
				String lemma = aMWEe.getAttribute("lemma");
				String cat = aMWEe.getAttribute("cat");
				String subcat = aMWEe.getAttribute("subcat");
				String mph = aMWEe.getAttribute("mph");
				String catints = ""; 
				String words = "";
				Boolean hasPartOfAmalgame = false;
				Boolean hasEmptyCatints = false;

				NodeList partOfMultiWordsnodeList = aMWEe.getChildNodes();

				//NodeList partOfMultiWordsnodeList  = null;
				//try {
				//	partOfMultiWordsnodeList = (NodeList) partOFMWxpath.evaluate(partOFMWexpression,aMWEe, XPathConstants.NODESET);
				//} catch (XPathExpressionException ex) {
				//	// TODO Auto-generated catch block
				//	ex.printStackTrace();
				//}

				// for each word partof mw 
				int numberOfPartOfWordsNotPartOfAmalgame = 0;
				int numberOfPartOfWords = 0; // should be partOfMultiWordsnodeList.getLength()
				for(int j=0; (j < partOfMultiWordsnodeList.getLength()); j++) {
					if (partOfMultiWordsnodeList.item(j) instanceof Element) {
						Element aPOMWE = (Element) partOfMultiWordsnodeList.item(j);

						String currentCatint = aPOMWE.getAttribute("catint");
						if (currentCatint.trim().equalsIgnoreCase("")) hasEmptyCatints = true;
						catints += " " + currentCatint;
						words += " " + aPOMWE.getTextContent().trim();
						//
						NodeList fils = aPOMWE.getChildNodes();
						// Si empty element
						if (fils.getLength() == 0) {
							hasPartOfAmalgame = true;
						}
						else numberOfPartOfWordsNotPartOfAmalgame++;
					}
					else {
						//System.err.println("Error: the current node is not an element as espected !");
						// not an error some of the mw have also text as nodes
					}
					numberOfPartOfWords++;
				}
				catints = catints.trim();
				words = words.trim();

				// if the lemma of the current mw node is known then update
				if (multiWordsExpressionHashMap.containsKey(lemma)) {
					//System.out.println("Info: Update");
					numberOfOccurrences++;
					multiWordsExpressionHashMap.put(lemma, (WordLemma) multiWordsExpressionHashMap.get(lemma).
							updateMultiWordExpression(cat, subcat, mph, catints, words, hasPartOfAmalgame, hasEmptyCatints,
									numberOfPartOfWordsNotPartOfAmalgame, numberOfPartOfWords));
				}
				// else create with initial values
				else {
					numberOfOccurrences++;
					distinctLemma++;
					multiWordsExpressionHashMap.put(lemma,new 
							WordLemma(lemma, cat, subcat, mph, catints, words, hasPartOfAmalgame, hasEmptyCatints, 
									numberOfPartOfWordsNotPartOfAmalgame, numberOfPartOfWords));
				}
			}
			else {
				System.err.println("Error: the current node is not an element as espected !");
			}
		}
		// in the whole document
		System.err.println("Info: # of multi-words lemma = "+distinctLemma+ ", occurrences = "+numberOfOccurrences);
		//System.err.println("Info: total # of multi-words occurrences = "+numberOfOccurrences);
		//System.err.println("Info: total # of multi-words occurrences in the whole document nodeList.getLength()  = "+nodeList.getLength());

		return multiWordsExpressionHashMap;
	}

	/**
	 * After having collected information coming from distinct occurrences of MW, generalize the information
	 */
	public void compilePropertiesFromMultiWords(WordLemmas multiWordLemmas) {
	
		Map<String,WordLemma> multiWordsExpressionHashMap = multiWordLemmas.getMultiWordLemmaMap(); 
		Map<String,Set<WordLemma>> multiWordsExpressionFirstWordMap  = multiWordLemmas.getMultiWordFirstWordMap();

		int mwWiAtLeastOneOccWiOneWordWoCatintsValue = 0;
		int mwLemmaWiNoCatintsPb = 0;
		int mwOccWiNoCatintsPb = 0;

		int mwWoCatints = 0;
		int mwWiOnlyOneCatints = 0;
		int mwWiOnlyOneCatintsButNotCoveringTheWholeMW = 0;
		int mwWiMultipleCatintsButIdentical = 0;

		int mwWiMultipleCatintsButIdenticalButNotCoveringTheWholeMW = 0;
		int mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalient = 0;// heuristic FB
		int mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole = 0;
		int mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientAndWoOneCoveringtheWhole = 0;
		int mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole = 0;
		int mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWoOneCoveringtheWhole = 0;

		int numberOfMWOccurrenceWiACatintIssue = 0;

		// TODO
		String mostProbableCatintSequence = "";

		Iterator<String> multiWordsExpressionHashMapKeyIterator = 	multiWordsExpressionHashMap.keySet().iterator();

		// For each lemma
		while (multiWordsExpressionHashMapKeyIterator.hasNext()) {
			WordLemma aMWE = multiWordsExpressionHashMap.get(multiWordsExpressionHashMapKeyIterator.next());

			//			Boolean canBeDesambiguated = false;

			// If the current MW has empty catints
			if (aMWE.getNumberOfNullCatintValue() >0) {
				mwWiAtLeastOneOccWiOneWordWoCatintsValue++;
				numberOfMWOccurrenceWiACatintIssue += aMWE.getOccurrence();

				List<String> aMWECatintsList = aMWE.getCatintsArrayList();
				// if no interpretation is available among the other mw occurrences
				if (aMWECatintsList.size() == 0) {
					mwWoCatints++;
					aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWoCatints);
				}
				// if only one interpretation is available among the other mw occurrences
				// i.e. aMWECatintsList.size() == 1
				// and numberOfPartOfWordsNotPartOfAmalgame
				else if (aMWECatintsList.size() == 1) {
					// searching the first longest catints sequence
					String currentCatints = aMWECatintsList.get(0); //catintsArrayListIterator.next();
					String[] currentCatintsArray =currentCatints.split(" ");
					if (currentCatintsArray.length == aMWE.getNumberOfPartOfWordsNotPartOfAmalgame()) {

						mwWiOnlyOneCatints++;
						aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiOnlyOneCatintsWhichCoversTheWholeMW);
						//						canBeDesambiguated = true;
						mostProbableCatintSequence = currentCatints;
						aMWE.setUniqCommonCatintsSequence(currentCatints);
					}
					else {
						mwWiOnlyOneCatintsButNotCoveringTheWholeMW++;
						aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiOnlyOneCatintsButNotCoveringTheWholeMW);
						//						aMWE.display();
					}
				}
				// if multiple interpretation available among the other mw occurrences
				else if (aMWECatintsList.size() > 1) {
					String[] aMWECatintsArray = aMWECatintsList.toArray(new String[0]);
					Boolean areAllInterpretationIdentical = true;

					Map<String,Integer> aMWECatintsMap = new HashMap<String,Integer>();

					String firstLongestCatintsSequence = "";
					int firstLongestCatintsSequenceSize = 0;

					// compute if All the catints are Identical 
					// the number of each catints forms
					// the first longest catints sequence
					for (int i = 0 ; i < aMWECatintsArray.length ; i++) {
						if ((i>0) && (!aMWECatintsArray[i-1].equalsIgnoreCase(aMWECatintsArray[i])))  
							areAllInterpretationIdentical = false;
						if (!aMWECatintsMap.containsKey(aMWECatintsArray[i])) 
							aMWECatintsMap.put(aMWECatintsArray[i], new Integer(1));
						else 
							aMWECatintsMap.put(aMWECatintsArray[i], aMWECatintsMap.get(aMWECatintsArray[i])+1);
						String currentCatints = aMWECatintsArray[i];
						String[] currentCatintsArray =currentCatints.split(" ");
						if (currentCatintsArray.length > firstLongestCatintsSequenceSize) {
							firstLongestCatintsSequence = currentCatints;
							firstLongestCatintsSequenceSize = currentCatintsArray.length ;
						}
					}

					// the multiple catints sequence are all identical
					// concequently the firstLongestCatintsSequence and firstLongestCatintsSequenceSize are the same for all
					if (areAllInterpretationIdentical) { 
						// mwWiOnlyOneCatints++; 
						// and cover the whole mw
						if (firstLongestCatintsSequenceSize == aMWE.getNumberOfPartOfWordsNotPartOfAmalgame()) {
							mwWiMultipleCatintsButIdentical++;
							aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsButIdenticalWhichCoversTheWholeMW);

							//							canBeDesambiguated = true;
							mostProbableCatintSequence = aMWECatintsArray[0];
							aMWE.setUniqCommonCatintsSequence(aMWECatintsArray[0]);
						}
						// and do not cover the whole mw
						else {
							mwWiMultipleCatintsButIdenticalButNotCoveringTheWholeMW++;
							aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsButIdenticalButNotCoveringTheWholeMW);
						}
					}

					else {
						// among the forms which are not identical, compute the number of sufficiently more salient
						// we evaluate if one catints is more salient than others (based on FB heuristic)

						TreeMap<String,Integer> aSortedMWECatintsMap = CollectionUtilities.sortStringIntegerHashMapByValue (aMWECatintsMap);


						// if the FB heuristic fires
						if (isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(aSortedMWECatintsMap)) {

							String[] aSortedMWECatintsMapArray = aSortedMWECatintsMap.firstKey().split(" ");

							// is the most FB salient catints sequence covering the whole mw
							// if yes, it is also the longest (firstLongestCatintsSequenceSize)
							if (aSortedMWECatintsMapArray.length == aMWE.getNumberOfPartOfWordsNotPartOfAmalgame()) {
								mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalient++;
								aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientWhichCoversTheWholeMW);
								//								canBeDesambiguated = true;
								mostProbableCatintSequence = aSortedMWECatintsMap.firstKey();
								aMWE.setMostFBSalientCatintsSequence(aSortedMWECatintsMap.firstKey());

							}
							else { 
								// does it exist a catints sequence covering the whole mw
								if (firstLongestCatintsSequenceSize == aMWE.getNumberOfPartOfWordsNotPartOfAmalgame()) {
									mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole++;
									aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole);

									//									canBeDesambiguated = true;
									// TODO could be by size of importance
									mostProbableCatintSequence = firstLongestCatintsSequence;
									aMWE.setMostFrequentCoveringCatintsSequence(firstLongestCatintsSequence);

								}
								// and do not cover the whole mw
								else {
									mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWoOneCoveringtheWhole++;
									aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWoOneCoveringtheWhole);

								}
							}
						}
						// Wi No sufficiently 
						else {
							// but with one longest covering the whole
							if (firstLongestCatintsSequenceSize == aMWE.getNumberOfPartOfWordsNotPartOfAmalgame()) {
								mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole++;
								aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole);

								//								canBeDesambiguated = true;
								mostProbableCatintSequence = firstLongestCatintsSequence;
								aMWE.setMostFrequentCoveringCatintsSequence(firstLongestCatintsSequence);

							}
							// and do not cover the whole mw
							else {
								mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientAndWoOneCoveringtheWhole++;
								aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientAndWoOneCoveringtheWhole);

							}
						}
					}
				}

				// TODO in compilePropertiesFromMultiWords 
				// remove addMostProbableCatintSequence and instead of, 
				// add aWordOccurrences here ? 
				// No. 
				// Add three string variables in MWLemma and define them in the previous code lines
				// Modify desambiguate where getMostProbableCatintSequence is called
				// In addition, in search where addMostProbableCatintSequence is called
				// change it for a add aWordOccurrences CollectionUtilities.incrementKeyValueCounter(word2CatMap, currentWordFormOcc, catSW);
				
				// Add the most probable assumed catint sequence
				if (!mostProbableCatintSequence.equalsIgnoreCase("")) {
					// For each lemma word forms 
					// assign the whatever most probable catint sequence identified to it
					Iterator <String >wordsIter = aMWE.getWordForms().iterator();
					while (wordsIter.hasNext()) {
						String wordsString = wordsIter.next();
						aMWE.addMostProbableCatintSequence(wordsString, mostProbableCatintSequence);
					}
				}

				// build a map of multiwords expression first words and multiwords expression
				// for each first word of all the word forms of the current MW
				Iterator<String> wordsIterator = aMWE.getWordForms().iterator();
				while (wordsIterator.hasNext()) {
					String wordsString = wordsIterator.next();
					String wordString[] = wordsString.split(" ");

					// add the current MW to the set of MW mapped by the first word form
					if (multiWordsExpressionFirstWordMap.containsKey(wordString[0])) {
						Set<WordLemma> mWSet = multiWordsExpressionFirstWordMap.get(wordString[0]);
						mWSet.add(aMWE);
					}
					else {
						Set<WordLemma> mWSet = new HashSet<WordLemma>();
						mWSet.add(aMWE);
						multiWordsExpressionFirstWordMap.put(wordString[0], mWSet);
					}

				}
			}
			else {
				mwLemmaWiNoCatintsPb++;
				mwOccWiNoCatintsPb+= aMWE.getOccurrence();
			}

		}

		//System.err.println("Info: total # of multi-words lemma = "+ (mwWiAtLeastOneOccWiOneWordWoCatintsValue + mwLemmaWiNoCatintsPb)
		//		+ " (with some catint issue "+ mwWiAtLeastOneOccWiOneWordWoCatintsValue
		//		+", without "+ mwLemmaWiNoCatintsPb+")");
		//System.err.println("Info: total # of multi-words occurrences  = "+ (numberOfMWOccurrenceWiACatintIssue + mwOccWiNoCatintsPb)
		//		+ " (with a catint issue "+ numberOfMWOccurrenceWiACatintIssue
		//		+", without "+ mwOccWiNoCatintsPb+")");

		System.err.println("Info: # of multi-words without catint issue lemma = "+ (mwLemmaWiNoCatintsPb)
				+ ", occurrences = "+ mwOccWiNoCatintsPb);
		System.err.println("Info: # of multi-words with catint issue lemma = "+ (mwWiAtLeastOneOccWiOneWordWoCatintsValue)
				+ ", occurences = "+ numberOfMWOccurrenceWiACatintIssue);

		//System.err.println("Info: # of multi-words lemma without catint issue  = "+mwLemmaWiNoCatintsPb);
		//System.err.println("Info: # of multi-words occurrences without catint issue  = "+mwOccWiNoCatintsPb);

		//System.err.println("Info: # of multi-words lemma with a catint issue (at least one word partOf wi no catint value) = "+mwWiAtLeastOneOccWiOneWordWoCatintsValue);
		//System.err.println("Info: # of multi-words occurrences with a catint issue (at least one word partOf wi no catint value) = "+numberOfMWOccurrenceWiACatintIssue);


		System.err.println("Info: # of multi-words lemma with no catints values = "+mwWoCatints);
		// base de calcul N, patron des patrons NC,  Trade Union Congress NP, remettre en question V, donner l'impressionV, 1 287 D/PRO, sur commande P,   à la mémoire de P

		System.err.println("Info: # of multi-words lemma with only one catints sequence which covers the whole mw = "+mwWiOnlyOneCatints);

		System.err.println("Info: # of multi-words lemma with only one catints sequence which do not covers the whole mw = "
				+mwWiOnlyOneCatintsButNotCoveringTheWholeMW);

		System.err.println("Info: # of multi-words lemma with multiple identical catints sequences which cover the whole mw  = "
				+mwWiMultipleCatintsButIdentical);
		// produit laitier  , mettre à la disposition, le Pas-de-Calais

		System.err.println("Info: # of multi-words lemma with multiple identical catints sequences and none of them covers the whole mw  = "
				+mwWiMultipleCatintsButIdenticalButNotCoveringTheWholeMW);

		System.err.println("Info: # of multi-words lemma with multiple distinct catints sequences and one sufficiently salient covering the whole mw = "+
				mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalient);

		System.err.println("Info: # of multi-words lemma with multiple distinct catints sequences and no sufficiently salient but one catints covering the whole mw = "+
				mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole);

		System.err.println("Info: # of multi-words lemma with multiple distinct catints sequences and no sufficiently salient and no catints covering the whole mw = "+
				mwWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientAndWoOneCoveringtheWhole);

		System.err.println("Info: # of multi-words lemma with multiple distinct catints sequences and one sufficiently salient not covering the whole mw but wi one catint covering the whole = "+
				mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole);

		System.err.println("Info: # of multi-words lemma with multiple distinct catints sequences and one sufficiently salient not covering the whole mw and wi none catint covering the whole = "+
				mwWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWoOneCoveringtheWhole);

	}

	/**
	 * return true if The First Form is More Salient Than Others Based On FB Heuristic
	 * 
	 */
	public Boolean isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(
			Map<String, Integer> map) {
		int valueOftheFirst = 0;
		int sumOfTheRest = 0;
		int j = 0;
		for(Map.Entry<String,Integer> entry : map.entrySet()) {
			//		String key = entry.getKey();
			Integer value = entry.getValue();
			if (j>0) sumOfTheRest +=  value;
			else valueOftheFirst = value;
			j++;
			//System.out.println(key + " => " + value);
		}

		// if the FB heuristic fires
		return (valueOftheFirst > sumOfTheRest);
	}

	/**
	 * return The First Form of a sorted Map
	 * 
	 */
	public String getTheFirstFormOfASortedMap(TreeMap<String, Integer> map) {
		return map.firstKey();
	}

	/**
	 * Search simple word sequences which correspond to multiwords components
	 * @param aWordForms TODO
	 *   
	 */
	public void searchSingleWordSequencesOfMultiWordsFromSimpleWordNodeList(
			List<WordAttributes> aWordAttributeList, 
			Map<String,Set<WordLemma>> multiWordsExpressionFirstWordMap, 
			WordForms aWordForms) {

		//for(int i=0; (i < nodeList.getLength()); i++) displayDomTree(nodeList.item(i));

		//Map<String,MultiWordExpression> multiWordsExpressionHashMap = new HashMap<String,MultiWordExpression>() ;

		int numberOfMWOccurrencesCorrespondingToASWSeq = 0;
		int numberOfMWWithAtLeastOneCorrespondingSWSeq = 0;
		int numberOfAlreadyDesambiguatedCaseCorrespondingToASWSeq =0;
		Set<String> numberOfMWWithSeveralSWSeqFeaturesSet = new HashSet<String>();

		// searching sw sequence corresponding to mw 
		// for each sw occ
		for(int i=0; (i < aWordAttributeList.size()); i++) {
			//if (sWNodeList.item(i) instanceof Element) {
			WordAttributes aSW = (WordAttributes) aWordAttributeList.get(i);
			String currentWordFormOcc = (String) aSW.getWord();
			//NamedNodeMap aSWattrs = aSW.getAttributes();
			//int numAttrsInCurrentSW = aSWattrs.getLength();
			//System.out.println("Debug: "+ aSW.getTagName()+" "+ aSW.getTextContent()+" numAttrs "+ numAttrsInCurrentSW);

			//System.out.println("Debug: if (multiWordsExpressionFirstWordMap.containsKey(aSW.getTextContent())) {");
			// if it exists a mw starting with this current word
			if (multiWordsExpressionFirstWordMap.containsKey(currentWordFormOcc)) {

				// for each MW starting with the same word
				Set<WordLemma> mWSet = 	multiWordsExpressionFirstWordMap.get(currentWordFormOcc);
				Iterator<WordLemma> mWSetIterator = mWSet.iterator();
				while (mWSetIterator.hasNext()) {
					WordLemma aMW = mWSetIterator.next();

					// if we are not at the end of the document
					// TODO should also consider the number of amalgame...
					if (aMW.getNumberOfPartOfWordsNotPartOfAmalgame()+i < aWordAttributeList.size()) {

						// check if there is sequence of simple word corresponding to the multi words
						// Identify if we are in presence of a form of the current MW starting with the same word
						Set<String> wordsSet = aMW.getWordsMap().keySet();
						Iterator<String> wordsIterator = wordsSet.iterator();
						// For each MW form
						while (wordsIterator.hasNext()) {
							String wordsString = wordsIterator.next();
							String wordArray[] = wordsString.split(" ");
							//System.out.println("Debug: wordsString "+wordsString+ " wordArray.length "+wordArray.length );

							// Do we consider the form which are not of the lemma size ? 
							// they may be ambiguous (belonging to various lemma)
							// no we don t
							if (aMW.getSize() == wordArray.length) {


								Boolean matched = true;
								// I do not know why, some multi words have only one word : Monde for "le monde"...
								// So a little hack
								//	
								/*for (int j = 1; j <wordArray.length ; j++ ) {
										for (int j = 0; j <wordArray.length ; j++ ) {
											//System.out.println("Debug: "+wordArray[j]+" compared to "+nodeList.item(i).getTextContent());
											// TODO unsecure if the following nodes are not Element
											if (!wordArray[j].equalsIgnoreCase(sWNodeList.item(i+j).getTextContent())) {
												matched = false;
											}
										}*/
								int j =0;

								// given the current mw form, we check word per word the alignement with a single word sequence
								while ((j <wordArray.length) && matched) {
									if (!wordArray[j].equalsIgnoreCase(aWordAttributeList.get(i+j).getWord())) {
										matched = false;
									}
									j++;
								}

								// one of the MW forms matches
								// it means we can take the information of the current sw seq for this MW 
								if (matched) {

									//String features = "";
									// for each single word of the 
									String catSeq = "";
									String subcatSeq = "";
									String lemmaSeq = "";
									String mphSeq = "";
									for (int l = 0; l <wordArray.length ; l++ ) {

										List<String> currentSW = (List<String>) aWordAttributeList.get(i+l);
										//NamedNodeMap currentSWattrs = currentSW.getAttributes();
										//int numberOfCurrentSWattrs = currentSWattrs.getLength();
										//System.out.println("Debug: "+ currentSW.getTagName()+" "+ currentSW.getTextContent()+" numAttrs "+ numberOfCurrentSWattrs);

										// Process each attribute
										catSeq += " "+(String)currentSW.get(0);
										subcatSeq += " "+(String)currentSW.get(1);
										lemmaSeq += " "+(String)currentSW.get(2);
										mphSeq += " "+(String)currentSW.get(3);

									}
									catSeq = catSeq.trim();
									subcatSeq = subcatSeq.trim();
									lemmaSeq = lemmaSeq.trim();
									mphSeq = mphSeq.trim();

									System.err.println("Debug: currentWordFormOcc >"+currentWordFormOcc+"<");
									// will overide any previous existing catint sequence assigned by MW analysis
									
									CollectionUtilities.incrementKeyCounter(
											aWordForms.getWordFormCatCounter(currentWordFormOcc).getCatMap(), 
											catSeq);

									// Count the subcat occurrences depending on the word forms + cat
									CollectionUtilities.incrementKeyCounter(
											aWordForms.getWordCatFormOtherCounters(currentWordFormOcc+" "+catSeq).getSubcatMap(), 
											subcatSeq);

									// Count the lemma occurrences depending on the word forms + cat
									CollectionUtilities.incrementKeyCounter(
											aWordForms.getWordCatFormOtherCounters(currentWordFormOcc+" "+catSeq).getLemmaMap(), 
											lemmaSeq);

									// Count the mph occurrences depending on the word forms + cat
									CollectionUtilities.incrementKeyCounter(
											aWordForms.getWordCatFormOtherCounters(currentWordFormOcc+" "+catSeq).getMphMap(), 
											mphSeq);


									aMW.addMostProbableCatintSequence(currentWordFormOcc, catSeq);
									aMW.addMostProbableSubcatSequence(currentWordFormOcc, subcatSeq);
									aMW.addMostProbableLemmaSequence(currentWordFormOcc, lemmaSeq);
									aMW.addMostProbableMphSequence(currentWordFormOcc, mphSeq);

									//features = features.trim();
									if (aMW.getMostProbableMphSequence().keySet().isEmpty()) {
										numberOfMWWithAtLeastOneCorrespondingSWSeq++;
										numberOfMWOccurrencesCorrespondingToASWSeq += aMW.getOccurrence();
									}
									//aMW.addFeaturesFromSWSeq(features);
									if (aMW.getMostProbableMphSequence().keySet().size() > 1) {
										numberOfMWWithSeveralSWSeqFeaturesSet.add(wordsString);
									}

									if (aMW.getDesambiguisationCase() != -1) numberOfAlreadyDesambiguatedCaseCorrespondingToASWSeq++;
									if (aMW.getNumberOfNullCatintValue() >0) 
										aMW.setDesambiguisationCase(MultiWordDesambiguationCase.MWWithACorrespondingSWSequence);
									//System.out.println("Debug: MATCHED "+wordsString+ " cats "+aMW.getCatsFromSWSeqSet().toString());
								}
							}
						}
					}
				}
			}

		}

		System.err.println("Info: # of multi words lemma with at least one corresponding simple word sequence = "+numberOfMWWithAtLeastOneCorrespondingSWSeq);
		System.err.println("Info: # of multi words occurrences with at least one corresponding simple word sequence  = "+numberOfMWOccurrencesCorrespondingToASWSeq);
		System.err.println("Info: # of multi words lemma with several simple word sequences  = "+numberOfMWWithSeveralSWSeqFeaturesSet.size());
		System.err.println("Info: # of corresponding to another ambiguous cat and corresponding to simple word sequences  = "+numberOfAlreadyDesambiguatedCaseCorrespondingToASWSeq);

	}


	/**
	 * Compute stats from sw occurrences
	 * @param aWordForms TODO
	 *   
	 */
	public List<WordAttributes> collectPropertiesFromSimpleWordNodesSax (
			File inputFile, 
			WordForms aWordForms) {

		SAXParserFactory parserFactory = SAXParserFactory.newInstance();

		FTBXMLSingleWordSaxHandler handler = new FTBXMLSingleWordSaxHandler (aWordForms);

		//try {
		SAXParser parser = null;
		try {
			parser = parserFactory.newSAXParser();
		} catch (ParserConfigurationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (SAXException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			//xmlStream.setEncoding("UTF-8");
			parser.parse(inputFile, handler);
		} catch (SAXException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		//} catch (Exception e) {
		//	throw new AnalysisEngineProcessException(e);
		//}

		return handler.getSingleWordOccAttributesList() ;
	}
	
	/**
	 * After having collected information coming from distinct occurrences of MW 
	 * and collected information from SW, generalize the information
	 * TODO en a t on vraiment l'utilité ?
	 */
	public void compilePropertiesFromSingleWords(Map<String,WordLemma> multiWordsExpressionHashMap, WordForms aWordForms) {

	/*	Map<String, Map<String, Integer>> word2CatMap = aWordOccurrences.getWord2CatMap();
		Map<String, Map<String, Integer>> wordCat2SubcatMap  = aWordOccurrences.getWordCat2SubcatMap();
		Map<String, Map<String, Integer>> wordCat2LemmaMap  = aWordOccurrences.getWordCat2LemmaMap();
		Map<String, Map<String, Integer>> wordCat2MphMap  = aWordOccurrences.getWordCat2MphMap();
*/
		Iterator<String> multiWordsExpressionHashMapKeyIterator = 	multiWordsExpressionHashMap.keySet().iterator();

		// for each mw lemma
		while (multiWordsExpressionHashMapKeyIterator.hasNext()) {
			WordLemma aMWE = multiWordsExpressionHashMap.get(multiWordsExpressionHashMapKeyIterator.next());

			// If the current MW has empty catints
			if (aMWE.getNumberOfNullCatintValue() >0) {
				// if it exists at least a sw sequence
				// for each whole form, provide the corresponding cat or the subcat or the mph 
				// the problem is to associate  the cat with the subcat and the mph
				// the solution could be a Map from the word+cat to ...
				// TODO ? process each MW later online or here

				// for each mw form
				Set<String> wordsSet = aMWE.getWordsMap().keySet();
				Iterator<String> wordsIterator = wordsSet.iterator();

				// For each MW form
				while (wordsIterator.hasNext()) {
					String wordsString = wordsIterator.next();
					String wordArray[] = wordsString.split(" ");

					// if it has the sufficient size
					if (aMWE.getSize() == wordArray.length) {

						//String features = "";
						// for each single word of the 
						String catSeq = "";
						String subcatSeq = "";
						String lemmaSeq = "";
						String mphSeq = "";

						Boolean undefinedCatintCase = false;
						Boolean undefinedSubcatCase = false;
						Boolean undefinedLemmaCase = false;
						Boolean undefinedMphCase = false;

						for (int l = 0; l <wordArray.length ; l++ ) {

							if (isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(aWordForms.getWordFormCatCounter(wordArray[l]).getCatMap())) 
								catSeq += " "+getTheFirstFormOfASortedMap((TreeMap<String, Integer>) aWordForms.getWordFormCatCounter(wordArray[l]).getCatMap());
							else undefinedCatintCase = true ;// catSeq += " U";
							if (!undefinedCatintCase) {
								if (isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getSubcatMap())) 
									subcatSeq += " "+getTheFirstFormOfASortedMap((TreeMap<String, Integer>) aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getSubcatMap());
								else undefinedSubcatCase = true ;//subcatSeq += " U";
								if (isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getLemmaMap())) 
									lemmaSeq += " "+getTheFirstFormOfASortedMap((TreeMap<String, Integer>) aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getLemmaMap());
								else undefinedLemmaCase = true ; // lemmaSeq += " U";
								if (isTheFirstFormMoreSalientThanOthersBasedOnFBHeuristic(aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getMphMap())) 
									mphSeq += " "+getTheFirstFormOfASortedMap((TreeMap<String, Integer>) aWordForms.getWordCatFormOtherCounters(wordArray[l]+" "+catSeq).getMphMap());
								else undefinedMphCase = true ; // mphSeq += " U";
							}
							else {
								undefinedSubcatCase = true ;
								undefinedLemmaCase = true ; 
								undefinedMphCase = true ; 
							}

						}
						if (!undefinedCatintCase) {
							catSeq = catSeq.trim();
							aMWE.addMostProbableCatintSequence(wordsString, catSeq);
						}

						if (!undefinedSubcatCase) {
							subcatSeq = subcatSeq.trim();
							aMWE.addMostProbableSubcatSequence(wordsString, subcatSeq);

						}
						if (!undefinedLemmaCase) {
							lemmaSeq = lemmaSeq.trim();
							aMWE.addMostProbableLemmaSequence(wordsString, lemmaSeq);

						}
						if (!undefinedMphCase) {
							mphSeq = mphSeq.trim();
							aMWE.addMostProbableMphSequence(wordsString, mphSeq);

						}
						//System.err.println("Debug: currentWordFormOcc >"+wordsString+"<");
						if (!undefinedCatintCase && !undefinedSubcatCase && !undefinedLemmaCase && !undefinedMphCase ) {

							/*						//features = features.trim();
						if (aMWE.getMostProbableMphSequence().keySet().isEmpty()) {
							numberOfMWWithAtLeastOneCorrespondingSWSeq++;
							numberOfMWOccurrencesCorrespondingToASWSeq += aMW.getOccurrence();
						}
						//aMW.addFeaturesFromSWSeq(features);
						if (aMWE.getMostProbableMphSequence().keySet().size() > 1) {
							numberOfMWWithSeveralSWSeqFeaturesSet.add(wordsString);
						}

						if (aMWE.getDesambiguisationCase() != -1) numberOfAlreadyDesambiguatedCaseCorrespondingToASWSeq++;
						if (aMWE.getNumberOfNullCatintValue() >0)*/ 
							aMWE.setDesambiguisationCase(MultiWordDesambiguationCase.MWWiIndependentFeaturesComputedFromSW);
							//System.out.println("Debug: MATCHED "+wordsString+ " cats "+aMW.getCatsFromSWSeqSet().toString());
						}
					}
				} 
			}
		}

	}

	/**
	 * Depending on the desambiguation case, desambiguate catints
	 */
	public void desambiguateMultiWords (NodeList nodeList, Map<String,WordLemma> multiWordsExpressionHashMap) {

		//	int distinctLemma = 0;

		Set<String> numberOfMWLemmaWhichCanBeDesambiguated = new HashSet<String>();
		int numberOfMWOccurrenceWhichCanBeDesambiguated = 0;

		Set<String> numberOfMWLemmaWhichCannotBeDesambiguated = new HashSet<String>();
		int numberOfMWOccurrenceWhichCannotBeDesambiguated = 0;

		Set<String> numberOfMWLemmaWhichDoNotNeedToBeDesambiguated = new HashSet<String>();
		int numberOfMWOccurrenceWhichDoNotNeedToBeDesambiguated = 0;

		// for each mw occurrences 
		for(int i=0; (i < nodeList.getLength()); i++) {
			if (nodeList.item(i) instanceof Element) {
				Element aMWElement = (Element) nodeList.item(i);

				// Compute MW characteristics
				String lemma = aMWElement.getAttribute("lemma");

				// multiWordsExpressionHashMap must contain the lemma
				// since it has been built by the same index
				if (multiWordsExpressionHashMap.containsKey(lemma)) {

					// current MWE object corresponding to the lemma
					WordLemma aMWEObject = multiWordsExpressionHashMap.get(lemma);

					// the current mwe requires a desambiguation
					// TODO Should process all the multi words not only whose with a catint issue
					if (aMWEObject.getNumberOfNullCatintValue() >0)  {

						// (1) si MWWithACorrespondingSWSequence 
						// 	   alors associe à toutes les formes les bonnes features et si il n y a pas de correspondance exacte associe quand même avec la 1ère ayant le même nombre de mots
						// (2) sinon si MWWiOnlyOneCatintsWhichCoversTheWholeMW or MWWiMultipleCatintsButIdenticalWhichCoversTheWholeMW
						// 			 alors utilise cela pour définir les cat et utilise FB pour subcat, lemma, et mph des autres features
						// (3) 		 sinon	si  MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientWhichCoversTheWholeMW or 
						// 					alors utilise cela pour définir les cat et utilise FB pour subcat, lemma, et mph des autres features
						// (4)				sinon	si MWWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole or MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole
						// 							alors utilise cela pour définir les cat et utilise FB pour subcat, lemma, et mph des autres features
						int desambiguationCase = aMWEObject.getDesambiguisationCase();

						Boolean desambiguate = false; 
						// (1) si MWWithACorrespondingSWSequence 
						// 	   alors associe à toutes les formes les bonnes features et si il n y a pas de correspondance exacte associe quand même avec la 1ère ayant le même nombre de mots
						if ((desambiguationCase ==  MultiWordDesambiguationCase.MWWithACorrespondingSWSequence)) { // (1) 
							numberOfMWLemmaWhichCanBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCanBeDesambiguated ++;
							desambiguate = true; 
						}
						else if ((desambiguationCase == MultiWordDesambiguationCase.MWWiOnlyOneCatintsWhichCoversTheWholeMW) // (2) 
								|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsButIdenticalWhichCoversTheWholeMW) 
								) {
							numberOfMWLemmaWhichCanBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCanBeDesambiguated ++;
							desambiguate = true; 

						} else if ( (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientWhichCoversTheWholeMW) // (3)
								) {
							numberOfMWLemmaWhichCanBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCanBeDesambiguated ++;
							desambiguate = true; 
						} else if ((desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientButWiOneCoveringtheWhole) // (4)
								|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWiOneCoveringtheWhole) 
								) {
							numberOfMWLemmaWhichCanBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCanBeDesambiguated ++;
							desambiguate = true; 
						} else if ((desambiguationCase ==  MultiWordDesambiguationCase.MWWiIndependentFeaturesComputedFromSW) // (5)
								) {
							numberOfMWLemmaWhichCanBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCanBeDesambiguated ++;
							desambiguate = true; 
						}
						else {
							// all the case we cannot desambiguate 
							//if ((desambiguationCase ==  MultiWordDesambiguationCase.MWWiOnlyOneCatintsButNotCoveringTheWholeMW) 
							//
							//	|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsButIdenticalButNotCoveringTheWholeMW) 
							//	|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWoCatints) 
							//	|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWoOneSufficientlyMoreSalientAndWoOneCoveringtheWhole) 
							//	|| (desambiguationCase ==  MultiWordDesambiguationCase.MWWiMultipleCatintsNotIdenticalWiOneSufficientlyMoreSalientNotCoveringTheWholeMWButWoOneCoveringtheWhole) ) {
							//
							//}
							numberOfMWLemmaWhichCannotBeDesambiguated.add(lemma);
							numberOfMWOccurrenceWhichCannotBeDesambiguated++;

							// TODO work with single word features 
						}
						// do the desambiguation (modify the dom)

						//if (desambiguate) {
						String occWordForm = aMWElement.getTextContent().trim();

						Map<String,String> catintsMap = aMWEObject.getMostProbableCatintSequence();
						Map<String,String> subcatsMap = aMWEObject.getMostProbableSubcatSequence();
						Map<String,String> lemmasMap = aMWEObject.getMostProbableLemmaSequence();
						Map<String,String> mphsMap = aMWEObject.getMostProbableMphSequence();

						String catintsString = catintsMap.get(occWordForm);
						String subcatsString = subcatsMap.get(occWordForm);
						String lemmasString = lemmasMap.get(occWordForm);
						String mphsString = mphsMap.get(occWordForm);

						String catintsStringArray[] = null;
						String subcatsStringArray[] = null;
						String lemmasStringArray[] = null;
						String mphsStringArray[] = null;

						Boolean undefinedCatintCase = false;
						Boolean undefinedSubcatCase = false;
						Boolean undefinedLemmaCase = false;
						Boolean undefinedMphCase = false;

						if (catintsString != null) {catintsStringArray = catintsString.split(" ");				}
						else {	
							undefinedCatintCase = true; 
							//System.err.println("Debug: catintsString null, occWordForm >"+occWordForm+"<");		

						}
						if (subcatsString != null) {subcatsStringArray = subcatsString.split(" ");	}
						else {
							undefinedSubcatCase = true; 
							//System.err.println("Debug: subcatsString null, occWordForm >"+occWordForm+"<");					
						}
						if (lemmasString != null) {	lemmasStringArray = lemmasString.split(" ");															}
						else {	
							undefinedLemmaCase = true; 	
							//System.err.println("Debug: lemmasString null occWordForm >"+occWordForm+"<");						
						}
						if (mphsString != null) { mphsStringArray = mphsString.split(" ");							}
						else {	
							undefinedMphCase = true; 							
							//System.err.println("Debug: mphsString null occWordForm >"+occWordForm+"<");							
						}

						NodeList partOfMultiWordsnodeList = aMWElement.getChildNodes();

						// 
						if (undefinedCatintCase && undefinedSubcatCase && undefinedLemmaCase && undefinedMphCase) {

							for(int j=0; (j < partOfMultiWordsnodeList.getLength()); j++) {
								if (partOfMultiWordsnodeList.item(j) instanceof Element) {
									Element aPOMWE = (Element) partOfMultiWordsnodeList.item(j);

									NodeList fils = aPOMWE.getChildNodes();
									// Si empty element
									// we do not modify amalgame part of word
									if (fils.getLength() != 0) {
										// TODO we overwrite existing catint value... which may be bad
										// we could use it to desambiguate...
										String catVal = "U";
										String subcatVal  = "U";
										String lemmaVal  = "U";
										String mphVal = "U";

										aPOMWE.setAttribute("catint", catVal);
										aPOMWE.setAttribute("subcat", subcatVal);
										aPOMWE.setAttribute("lemma", lemmaVal);
										aPOMWE.setAttribute("mph", mphVal);
									}
								}
							}
						}
						else	
							// can hold since catintsStringArray does not consider amalgame and partOfMultiWordsnodeList does
							//if (catintsStringArray.length == partOfMultiWordsnodeList.getLength() || undefinedCatintCase|| undefinedSubcatCase|| undefinedLemmaCase|| undefinedMphCase) {
						{
							// for each word partof mw 
							int s =0;
							int t = 0;
							while (t < partOfMultiWordsnodeList.getLength()) {
								if (partOfMultiWordsnodeList.item(t) instanceof Element) {
									Element aPOMWE = (Element) partOfMultiWordsnodeList.item(t);

									NodeList fils = aPOMWE.getChildNodes();
									// Si empty element
									// in order to handle the amalgame word part of multi word
									if (fils.getLength() != 0) {
										s++;
									}


									// TODO we overwrite existing catint value... which may be bad
									// we could use it to desambiguate...
									String catVal = "U";
									String subcatVal  = "U";
									String lemmaVal  = "U";
									String mphVal = "U";

									//System.err.println("Debug: occWordForm "+occWordForm+" s "+ s);

									//System.err.println("Debug: catintsStringArray[s] "+ catintsStringArray[s]);
									if (!undefinedCatintCase) catVal =  catintsStringArray[s];
									if (!undefinedSubcatCase) subcatVal =  subcatsStringArray[s];
									if (!undefinedLemmaCase) lemmaVal =  lemmasStringArray[s];
									if (!undefinedMphCase) mphVal =  mphsStringArray[s];

									aPOMWE.setAttribute("catint", catVal);
									aPOMWE.setAttribute("subcat", subcatVal);
									aPOMWE.setAttribute("lemma", lemmaVal);
									aPOMWE.setAttribute("mph", mphVal);

								}
								t++	;
								//else {
								//	System.err.println("Debug: partOfMultiWordsnodeList.item(j) is not instanceof Element");
								//}

							}

							//}
							//else {
							//	System.err.println("Warning: this multi word lemma have at least two distinct forms with different size ("+lemma+" occurs here as "+occWordForm+")");
							//}
						}
						//
						//aMWEObject.display();

						//}
					}
					else {
						// which do not need 
						numberOfMWOccurrenceWhichDoNotNeedToBeDesambiguated++;
						numberOfMWLemmaWhichDoNotNeedToBeDesambiguated.add(lemma);
						//numberOfMWOccurrenceWhichDoNotNeedToBeDesambiguated += aMWEObject.getOccurrence();
					}
				}
				else {
					System.err.println("Error: a aap's key is missing from an index which previously was used to build the map");
				}
			}
		}

		System.err.println("Info: # of multi-words which do not need to be desambiguated ; lemma = "+numberOfMWLemmaWhichDoNotNeedToBeDesambiguated.size()
				+ ", occurrences = "+numberOfMWOccurrenceWhichDoNotNeedToBeDesambiguated);
		//System.err.println("Info: # of multi-words occurrences which do not need to be desambiguated = "+ 
		//		numberOfMWOccurrenceWhichDoNotNeedToBeDesambiguated);
		System.err.println("Info: # of multi-words we can desambiguate lemma  = "+ numberOfMWLemmaWhichCanBeDesambiguated.size()
				+ ", occurrences = "+numberOfMWOccurrenceWhichCanBeDesambiguated);
		//System.err.println("Info: # of multi-words lemma we cannot desambiguate = "+ 
		//		numberOfMWOccurrenceWhichCanBeDesambiguated);
		System.err.println("Info: # of multi-words we do not manage to desambiguate lemma = "+ 
				numberOfMWLemmaWhichCannotBeDesambiguated.size()+ ", occurrences = "+numberOfMWOccurrenceWhichCannotBeDesambiguated);
		//System.err.println("Info: # of multi-words occurrences we cannot desambiguate = "+ 
		//		numberOfMWOccurrenceWhichCannotBeDesambiguated);
	}

}